glglyphcache: Remove surface member from dirty glyph
authorTimm Bäder <tbaeder@redhat.com>
Fri, 8 Feb 2019 10:01:39 +0000 (11:01 +0100)
committerTimm Bäder <mail@baedert.org>
Sun, 10 Feb 2019 09:31:27 +0000 (10:31 +0100)
We don't use it after we've rendered to it, just its size and data.

gsk/gl/gskglglyphcache.c
gsk/gl/gskglglyphcacheprivate.h

index dc8d5149a97a0733d2546fceac9dc08f5f509318..655da906ab7cb19e5de435b3f0ea4a5824fb4240 100644 (file)
@@ -29,7 +29,6 @@ static gboolean glyph_cache_equal      (gconstpointer v1,
                                         gconstpointer v2);
 static void     glyph_cache_key_free   (gpointer      v);
 static void     glyph_cache_value_free (gpointer      v);
-static void     dirty_glyph_free       (gpointer      v);
 
 static GskGLGlyphAtlas *
 create_atlas (GskGLGlyphCache *cache)
@@ -129,15 +128,6 @@ glyph_cache_value_free (gpointer v)
   g_free (v);
 }
 
-static void
-dirty_glyph_free (gpointer v)
-{
-  DirtyGlyph *glyph = v;
-
-  if (glyph->surface)
-    cairo_surface_destroy (glyph->surface);
-}
-
 static void
 add_to_cache (GskGLGlyphCache  *cache,
               GlyphCacheKey    *key,
@@ -249,14 +239,17 @@ render_glyph (const GskGLGlyphAtlas *atlas,
   pango_cairo_show_glyph_string (cr, key->font, &glyph_string);
   cairo_destroy (cr);
 
-  glyph->surface = surface;
+  cairo_surface_flush (surface);
 
-  region->data = cairo_image_surface_get_data (surface);
   region->width = cairo_image_surface_get_width (surface);
   region->height = cairo_image_surface_get_height (surface);
   region->stride = cairo_image_surface_get_stride (surface);
+  region->data = g_memdup (cairo_image_surface_get_data (surface),
+                           region->stride * region->height * sizeof (guchar));
   region->x = (gsize)(value->tx * atlas->width);
   region->y = (gsize)(value->ty * atlas->height);
+
+  cairo_surface_destroy (surface);
 }
 
 static void
@@ -271,7 +264,8 @@ upload_dirty_glyph (GskGLGlyphCache *self,
 
   gsk_gl_image_upload_regions (atlas->image, self->gl_driver, 1, &region);
 
-  dirty_glyph_free (&atlas->pending_glyph);
+  g_free (region.data);
+
   atlas->pending_glyph.key = NULL;
   atlas->pending_glyph.value = NULL;
 }
index d93bbdcfc69e62c747341c5a0ab02e34cf2161e3..00c3dab95cfa1adcd450cdc081fd8264ab965396 100644 (file)
@@ -32,7 +32,6 @@ struct _DirtyGlyph
 {
   GlyphCacheKey *key;
   GskGLCachedGlyph *value;
-  cairo_surface_t *surface;
 };
 
 typedef struct